/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
const twoSum = function(nums, target) {
    for (let i = 0; i < nums.length; i++) {
        for (let j = i+1; j < nums.length; j++) {
            if (target === nums[i] + nums[j]) {
                return [i,j];
            }
        }
    }
    return[0,0];
};

console.log(twoSum([3,2,4], 6));


const twoSum = function(nums, target) {
    const hash = {};
    for (let i = 0; i < nums.length; i++) {
        const res = target - nums[i];
        if(hash[res]!==undefined){
            return [hash[res],i];
        }
        hash[nums[i]] = i;
    }

};

console.log(twoSum([3,2,4], 6));